<?php 
    class Order_model extends CI_Model{

        function __construct(){
            parent::__construct();
        }

        function get_order_list($limit,$offset,$school_id = 0){
            $where = " 1=1 ";//" order_type = $type ";
            if($school_id>0){
                $where .= " and school_id=$school_id ";
            }
            $sql = "SELECT SQL_CALC_FOUND_ROWS o.*,s.school_name FROM {$this->db->dbprefix}shopping_orders o left join {$this->db->dbprefix}o2o_school s on s.id = o.school_id where $where order by order_id desc limit $limit,$offset";
            $result = $this->db->query($sql)->result_array();
            $row_num =  $this->db->query('SELECT FOUND_ROWS() as row_num;')->row_array();
            return array("count" => $row_num['row_num'], "result" => $result);
        }
    }